//
//  GetSpotTask.m
//  ZooNgonDoiOS
//
//  Created by Anh Jun Linh Tinh on 7/5/12.
//  Copyright (c) 2012 Personal. All rights reserved.
//

#import "GetSpotTask.h"
#import "RestKit/JSONKit.h"
#import "ZooSpotBean.h"

@implementation GetSpotTask
-(id)initWithParams:(NSString *)spotId{
    self = [super init];
    if(self){
        _spotId = spotId;
    }
return self;
}

-(void)doExecute{
    NSDictionary *params = [NSDictionary dictionaryWithObject:_spotId forKey:@"spot_id"];
    [[RKObjectManager sharedManager].client get:@"/spot" queryParameters:params delegate:self];
}

-(void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error{
    
}
-(void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response{
    
    NSString *jsonString = [response bodyAsString];
    NSDictionary *json = [jsonString objectFromJSONString];
    NSDictionary *object = [json objectForKey:@"info"];
    ZooSpotBean *spotBean = [[ZooSpotBean alloc] init];
    spotBean.name = [object objectForKey:@"name"];
    spotBean.address = [object objectForKey:@"address"];
    
    //Call back spotbean
}
@end
